package com.pie4cloud.pie.dmz.handler;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

public class NettyInitializerFilter<T> extends ChannelInitializer<SocketChannel> {

	private T t;

	public NettyInitializerFilter(T t) {
		this.t = t;
	}

	@Override
	protected void initChannel(SocketChannel socketChannel) throws Exception {
		ChannelPipeline pipeline = socketChannel.pipeline();
		pipeline.addLast(new MsgEncoder());
		pipeline.addLast(new MsgDecoder());
		pipeline.addLast((ChannelHandler) t);
	}
}